/** * Override or insert PHPTemplate variables into the templates. */ function phptemplate_preprocess_page(&$vars) { $vars['tabs2'] = menu_secondary_local_tasks(); // Hook into color.module if (module_exists('color')) { _color_page_alter($vars); } // Construct page title if (drupal_get_title()) { $head_title = array(strip_tags(drupal_get_title()), variable_get('site_name', 'Drupal')); } else { $head_title = array(variable_get('site_name', 'Drupal')); if (variable_get('site_slogan', '')) { $head_title[] = variable_get('site_slogan', ''); } } $crumb = drupal_get_breadcrumb(); $c = count($crumb); if(strip_tags($crumb[3])=="Hadith") { unset($crumb[3]); } if(strip_tags($crumb[2])=="Hadith") { $val = arg(2); switch ($val) { case "SAD" : $a[$c-1] = "Abu-Dawood"; $crumb=array_merge($crumb,$a); break; case "AMH" : $a[$c-1] = "Al-Muwatta"; $crumb=array_merge($crumb,$a); break; case "HDQ" : $a[$c-1] = "Al-Qudsi"; $crumb=array_merge($crumb,$a); break; case "TIR" : $a[$c-1] = "Al-Tirmidhi"; $crumb=array_merge($crumb,$a); break; case "fiq" : $a[$c-1] = "Fiqh-us-Sunnah"; $crumb=array_merge($crumb,$a); break; case "SHB" : $a[$c-1] = "Sahih Al-Bukhari"; $crumb=array_merge($crumb,$a); break; case "SHM" : $a[$c-1] = "Sahih Muslim"; $crumb=array_merge($crumb,$a); break; } } if(arg(3)=='english') { $val = arg(5); switch ($val) { case "TLT" : $a[$c-1] = "Transliteration"; $crumb=array_merge($crumb,$a); break; } switch ($val) { case "ASD" : $a[$c-1] = "Asad Translation"; $crumb=array_merge($crumb,$a); break; } switch ($val) { case "MAL" : $a[$c-1] = "Malik Translation"; $crumb=array_merge($crumb,$a); break; } switch ($val) { case "PIK" : $a[$c-1] = "Pickthall Translation"; $crumb=array_merge($crumb,$a); break; } switch ($val) { case "YAT" : $a[$c-1] = "Yusuf Ali Translation"; $crumb=array_merge($crumb,$a); break; } } if(arg(3)=='introduction') { $val = arg(5); switch ($val) { case "MAL" : $a[$c-1] = "Malik Surah Introductions"; $crumb=array_merge($crumb,$a); break; } switch ($val) { case "QSI" : $a[$c-1] = "Maududi Surah Introductions"; $crumb=array_merge($crumb,$a); break; } } if(strip_tags($crumb[$c-1])=="Hadith Narrator Index") { unset($crumb[$c-1]); } if(arg(2)=='subject' && arg(3)!='ayah') { unset($crumb[$c-1]); } if(arg(2)=='duas' && arg(3)=='content') { unset($crumb[$c-1]); } if(strip_tags($crumb[$c-1])=="Fiqh-us-Sunnah") { unset($crumb[$c-1]); } if(arg(2)=='islamposters' && arg(3)=='content') { // unset($crumb[$c-1]); } if(arg(2)=='narrator') { unset($crumb[$c-1]); } if(arg(2)=='narrators') { unset($crumb[$c-1]); } if(arg(2)=='khalifa' && arg(3)=='content') { unset($crumb[$c-1]); } if(arg(2)=='companion' && arg(3)=='content') { unset($crumb[$c-1]); } if(arg(1)=='163607') { unset($crumb[$c-1]); } if($c > 1 ){ unset($crumb[0]); } $crumblast = strip_tags($crumb[$c-1]); if($crumblast != '' ){ if(@substr_count($head_title,$crumblast) > 0 ){ unset($crumb[$c-1]); } } $crumb = array_reverse($crumb); if (drupal_get_title()) { //unset($crumb[$c-1]); $newhead_tit = strip_tags(implode(' | ', $crumb )); if(count($head_title)>1) { $vars['head_title'] = $head_title[0].' | '.$head_title[1]; } else { $vars['head_title'] = $newhead_tit.' | '.$head_title[0]; } } else{ $newhead_tit = strip_tags(implode(' | ', $crumb )); if(count($head_title)>1) { $vars['head_title'] = $head_title[0].' | '.$newhead_tit.' | '.$head_title[1]; } else { $vars['head_title'] = $newhead_tit.' | '.$head_title[0]; } } if(arg(1)=='163647') { $vars['head_title'] = 'Widgets | Alim.org'; } if(arg(0)=='recentcomments') { $vars['head_title'] = 'Recent Comments | Alim.org'; } if(arg(1)=='163664') { $vars['head_title'] = 'Donate| Alim.org'; } if(arg(1)=='163663') { $vars['head_title'] = 'Donate | Alim.org'; } if(arg(1)=='scholarpage') { $vars['head_title'] = 'Advisers and Scholars Details | Our Advisers and Scholars | Alim.org'; } if(arg(2)=='our-advisers-and-scholars') { $vars['head_title'] = 'Submit Advisers and Scholars | Our Advisers and Scholars | Alim.org'; } if(arg(2)=='our-advisers-and-scholars') { unset($vars['title']); //drupal_set_title('Submit Advisers and Scholars') $vars['title'] = 'Submit Advisers and Scholars'; } # User Profile, alter the title directly by cheking each page URl if(arg(0)=='userprofile') { $vars['head_title'] = 'Profile | Alim.org'; } if(arg(0)=='node' && arg(2)=='edit') { unset($breadcrumb); $vars['head_title'] = 'Edit Group | Profile | Alim.org'; } if(arg(0)=='node' && arg(2)=='delete') { unset($breadcrumb); $vars['head_title'] = 'Delete Group | Profile | Alim.org'; } if(arg(0)=='searchusers') { $vars['head_title'] = 'Search Users | Profile | Alim.org'; } if(arg(0)=='searchgroups'){ $vars['head_title'] = 'Search Groups | Profile | Alim.org'; } if(arg(0)=='relationships'){ $vars['head_title'] = 'My Relationships | Profile | Alim.org'; } if(arg(1)=='create_admin') { $vars['head_title'] = 'Confirm Admin | Group Members | Manage Groups | Profile | Alim.org'; } if(arg(1)=='subscribe') { $vars['head_title'] = 'Join Group | Profile | Alim.org'; } if(arg(1)=='unsubscribe') { $vars['head_title'] = 'Leave Group | Profile | Alim.org'; } if(arg(1)=='delete_admin') { $vars['head_title'] = 'Remove Admin | Profile | Alim.org'; } if(arg(1)=='scholarpage') { $vars['head_title'] = 'Advisers and Scholars Details | Our Advisers and Scholars | Alim.org'; } if(arg(2)=='dictionary') { $vars['head_title'] = 'Islamic Terms Dictionary | References | Qur\'an & Hadith | Alim.org'; } if(arg(0)=='recent-group-posts'){ $vars['head_title'] = 'Recent Group Posts | Alim.org'; } if(arg(1)=='all-recent-tags') { $vars['head_title'] = 'Recent Tags | Alim.org'; } if(arg(1)=='clippings') { $vars['head_title'] = 'Home | My Notebook | Alim.org'; } if(arg(0) == 'bookmarks') { $vars['head_title'] = 'Home | Bookmarks | Alim.org'; } if(arg(0)=='relationships') { alim_removetab('All', $vars);} if(arg(0)=='user' && arg(2)=='edit') { $vars['head_title'] = 'Edit Profile | Alim.org'; alim_removetab('View', $vars); alim_removetab('Edit', $vars); alim_removetab('Notifications', $vars); alim_removetab('3rd party identities', $vars); } global $user; $arr_role = $user->roles; if(in_array("Developer", $arr_role)==FALSE && in_array("System Administrator", $arr_role)==FALSE) { if(arg(0)=='node' && arg(2)=='edit') { //alim_removetab('View', $vars); //alim_removetab('Edit', $vars); alim_removetab('Broadcast', $vars); } } if(arg(2)=='our-advisers-and-scholars') { $vars['head_title'] = 'Submit Advisers and Scholars | Our Advisers and Scholars | Alim.org'; } if(arg(1)==163997) { $vars['head_title'] = 'Alim Content Sources | References| Qur\'an & Hadith|Alim.org'; } if(arg(2)=='AlQuran-tafsir') { $vars['head_title'] = 'AlQuran-tafsir | Qur\'an & Hadith | Alim.org'; } // Remove the tabs from pages. alim_removetab('Your votes', $vars); alim_removetab('Twitter', $vars); alim_removetab('Bookmarks', $vars); alim_removetab('Preset Bookmarks', $vars); jquery_ui_add(array('ui.draggable', 'ui.dialog')); jquery_ui_add(array('ui.draggable')); drupal_add_js(drupal_get_path('module', 'alim_searchtags') .'/mybookmarkmenu.js'); if(arg(1)=='biography') { drupal_add_js(drupal_get_path('theme', 'alim') . '/scroll_menu/c_config.js'); drupal_add_js(drupal_get_path('theme', 'alim') . '/scroll_menu/c_smartmenus.js'); drupal_add_js(drupal_get_path('theme', 'alim') . '/scroll_menu/c_addon_scrolling.js'); } drupal_add_js(drupal_get_path('theme', 'alim') . '/crawler.js'); drupal_add_js(drupal_get_path('theme', 'alim') . '/galleryview/jquery.timers-1.2.js'); drupal_add_js(drupal_get_path('theme', 'alim') . '/galleryview/jquery.easing.1.3.js'); drupal_add_js(drupal_get_path('theme', 'alim') . '/dhtml_menu/animatedcollapse.js'); drupal_add_js(drupal_get_path('theme', 'alim') . '/hoverjq.js'); $vars['scripts'] = drupal_get_js(); drupal_add_css(drupal_get_path('theme', 'alim') . '/galleryview/galleryview.css'); drupal_add_css(drupal_get_path('theme', 'alim') . '/splash.css'); $vars['styles'] = drupal_get_css(); alim_removetab('Voting details', $vars); if (arg(0) == 'bookmarks') { $vars['tabs'] = str_replace('Add item</span></a>', 'Add folder</span></a>', $vars['tabs']); $vars['tabs'] = str_replace('List items</span></a>', 'Manage Bookmarks</span></a>', $vars['tabs']); } //alim_removetab('Voting details', $vars); //alim_removetab('Search Lucene', $vars); //if(arg(0) == 'search' ) //alim_removetab('Content', $vars); $vars['bookmark'] = bookmark(); }
if (like($user_id, $msg_id, 1) === false) { die('Query failed'); } } else { if (!strcmp($action, "dislike")) { if (like($user_id, $msg_id, -1) === false) { die('Query failed'); } } else { if (!strcmp($action, "bookmark")) { if (bookmark($user_id, $msg_id, true) == false) { die('Query failed'); } } else { if (!strcmp($action, "unbookmark")) { if (bookmark($user_id, $msg_id, false) == false) { die('Query failed'); } } else { if (!strcmp($action, "closethread") || !strcmp($action, "openthread")) { $query = "SELECT t.author as t_author, t.properties as t_properties, t.id as thread_id from confa_threads t, confa_posts p where p.thread_id = t.id and p.id=" . $msg_id; $result = mysql_query($query); if (!$result) { mysql_log(__FILE__, 'query failed ' . mysql_error() . ' QUERY: ' . $query); die('Query failed'); } $row = mysql_fetch_assoc($result); if ($user_id == $row['t_author']) { $thread_id = $row['thread_id']; $value = 0; if (!strcmp($action, "closethread")) {
$action = $_POST["action"]; switch ($action) { case 'subscribe_forum': subscribe(); break; case 'unsubscribe_forum': unsubscribe(); break; case 'subscribe_topic': subscribe_topic(); break; case 'unsubscribe_topic': unsubscribe_topic(); break; case 'bookmark': bookmark(); break; case "test": test_function(); break; } } else { die; } } /* * Determine if a valid ajax request */ function is_ajax() { return isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest';
} return $response; }); /** * DELETE /messages/$id/bookmark */ $app->delete('/api/messages/{id:[0-9]+}/bookmark', function ($msg_id) { global $logged_in, $user_id, $err_login; $response = new Response(); if (!$logged_in) { $response->setStatusCode(403, 'Authentication error'); $response->setContentType('application/json'); $response->setJsonContent(array('status' => 'ERROR', 'messages' => array(is_null($err_login) ? "User not logged in" : $err_login))); return $response; } $new_value = bookmark($user_id, $msg_id, false); if ($new_value === false) { $response->setStatusCode(400, 'Error'); $response->setContentType('application/json'); $response->setJsonContent(array('status' => 'ERROR', 'messages' => array(mysql_error()))); } return $response; }); /** * POST /threads */ $app->post('/api/threads', function () use($app) { return api_post($app, 0, 0); }); /** * POST /messages/$id/answers