Esempio n. 1
0
 public function onModifyPageWatchRedirects(umiEventPoint $e)
 {
     static $links = array();
     $redirects = redirects::getInstance();
     $hierarchy = umiHierarchy::getInstance();
     $element = $e->getRef('element');
     if ($element instanceof umiHierarchyElement == false) {
         return false;
     }
     $elementId = $element->getId();
     $link = $hierarchy->getPathById($elementId, false, false, true);
     if ($e->getMode() == 'before') {
         $links[$elementId] = $link;
         return true;
     }
     if ($links[$elementId] != $link) {
         $redirects->add($links[$elementId], $link, 301);
     }
 }
Esempio n. 2
0
 public function onModifyPropertyValue(umiEventPoint $e)
 {
     $object = $e->getRef('entity');
     $objectId = $object->getId();
     $objectType = umiObjectTypesCollection::getInstance()->getType($object->getTypeId());
     if ($objectType->getModule() != 'users' || $objectType->getMethod() != 'user') {
         return;
     }
     if ($e->getMode() == "before") {
         $newValue =& $e->getRef('newValue');
         switch ((string) $e->getParam('property')) {
             case 'name':
                 $newValue = $this->validateLogin($newValue, $objectId);
                 break;
             case 'e-mail':
                 $newValue = $this->validateEmail($newValue, $objectId);
                 break;
             default:
                 return;
         }
         $this->errorThrow('xml');
     }
     if ($e->getMode() == "after") {
         switch ((string) $e->getParam('property')) {
             case 'login':
                 $object->name = (string) $e->getParam('newValue');
                 $object->commit();
                 break;
             case 'name':
                 $object->login = (string) $e->getParam('newValue');
                 $object->commit();
                 break;
             default:
                 return;
         }
     }
 }