Turba::hasMaxContacts PHP 메소드

hasMaxContacts() 공개 정적인 메소드

Checks the max_contacts permission.
public static hasMaxContacts ( Turba_Driver $driver, boolean $notify = true ) : string
$driver Turba_Driver The address book to check.
$notify boolean If true, outputs error to notification.
리턴 string Error message if maximum contacts have been reached. False otherwise.
    public static function hasMaxContacts(Turba_Driver $driver, $notify = true)
    {
        $error = false;
        $max_contacts = Turba::getExtendedPermission($driver, 'max_contacts');
        if ($max_contacts !== true && $max_contacts <= count($driver)) {
            $error = sprintf(_("You are not allowed to create more than %d contacts in \"%s\"."), $max_contacts, $driver->title);
            Horde::permissionDeniedError('turba', 'max_contacts', $notify ? $error : null);
        }
        return $error;
    }

Usage Example

예제 #1
0
파일: add.php 프로젝트: horde/horde
/* Exit with an error message if there are no sources to add to. */
if (!$addSources) {
    $notification->push(_("There are no writeable address books. None of the available address books are configured to allow you to add new entries to them. If you believe this is an error, please contact your system administrator."), 'horde.error');
    $url = $url ? Horde::url($url, true) : Horde::url('index.php', true);
    $url->redirect();
}
/* A source has been selected, connect and set up the fields. */
if ($source) {
    try {
        $driver = $injector->getInstance('Turba_Factory_Driver')->create($source);
    } catch (Turba_Exception $e) {
        $notification->push($e, 'horde.error');
        $driver = null;
    }
    if (!is_null($driver)) {
        if (Turba::hasMaxContacts($driver)) {
            $url = $url ? Horde::url($url, true) : Horde::url('index.php', true);
            $url->redirect();
        }
        $contact = new Turba_Object($driver);
    }
}
/* Set up the form. */
$form = new Turba_Form_AddContact($vars, $contact);
/* Validate the form. */
if ($form->validate()) {
    $form->execute();
}
Horde::startBuffer();
$notification->notify(array('listeners' => 'status'));
$form->renderActive($form->getRenderer(), $vars, Horde::url('add.php'), 'post');
All Usage Examples Of Turba::hasMaxContacts