Beispiel #1
0
 public function restore($paths)
 {
     if (!is_array($paths)) {
         $paths = array($paths);
     }
     /* collecting ids from paths */
     $ids = array();
     foreach ($paths as $path) {
         $id = explode('/', $path);
         $id = array_pop($id);
         if (!is_numeric($id)) {
             return array('success' => false);
         }
         if (!Security::canDelete($id)) {
             throw new \Exception(L\get('Access_denied'));
         }
         $ids[] = intval($id);
     }
     if (empty($ids)) {
         return array('success' => false);
     }
     /* before deleting we should check security for specified paths and all children */
     /* if access is granted then setting dstatus=0 for specified ids
        all their children /**/
     foreach ($ids as $id) {
         $obj = Objects::getCustomClassByObjectId($id);
         $obj->restore();
     }
     Solr\Client::runCron();
     return array('success' => true, 'ids' => $ids);
 }